<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <title>撮合服务管理-${titleName }</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/sale/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/sale/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-info">
             <!--搜索title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-cog"></i> 撮合服务</h3>
                 <div class="box-tools pull-right">
                 </div>
              </div>
            <!--搜索title  end --> 
            <div class="box-body">
			  <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="doCode" value="dymicSql"/>
				<input type="hidden" name="pageName" value="">
				<input type="hidden" name="formName" value="">
				
			   <div class="form-group col-sm-12">	  
				   	<div class="col-sm-3 text_r"><label class="control-label" >运行状态：</label></div>
					<div class="col-sm-5">
					 <label id="match_status" class="control-label"></label>
					</div>
					<div class="col-sm-4">
						<button type="button" class="btn btn-danger" onclick="initMatch('restart');"><i class="fa fa-edit"></i> 重启服务</button> &nbsp;&nbsp;
					</div>
				</div>
				       
			  </form>
            </div>
	     </div>
	     <!------- 搜索 end -------->
	     
	     <div class="row">
            	<!-- 1.开盘价 -->  
			   <div class="col-sm-12">
			   		<div class="box box-warning">
				   		<div class="box-header"><h3 class="box-title"><i class="fa fa-cog"></i> 开盘价</h3></div>
		              	<div class="form-group box-footer">
		              		<div class="col-sm-10">
								<label  class="col-sm-4 control-label">日期</label>
								<div class="col-sm-5">
									<div class="input-append date form_datetime">
										    		<input style="width:88%" id="lastDate"  type="text" class="form-control datepicker" value="" readonly/>
										    		<span class="add-on"><i class="fa fa-calendar"></i></span>
									</div>
<%--						  			<input type="text" id="lastDate"  placeholder="yyyy-MM-dd" maxlength="10" class="form-control"/>--%>
								</div>
							</div>
							<div class="col-sm-2">
				       			<button type="button" class="btn btn-success" onclick="initOpenPrice();"> 初始化开盘价</button> 
				       		</div>
		         	 	</div>
					</div>
				</div>
				
				<!-- 2.收盘价 
			   <div class="col-sm-5">
			   		<div class="box box-warning">
				   		<div class="box-header"><h3 class="box-title"><i class="fa fa-cog"></i> 收盘价</h3></div>
		              	<div class="form-group box-footer">
		              		<div class="col-sm-7">
								<label  class="col-sm-4 control-label">日期</label>
								<div class="col-sm-8">
						  			<input type="text" id="lastDate"  placeholder="yyyy-MM-dd" maxlength="10" class="form-control"/>
								</div>
							</div>
							<div class="col-sm-5">
				       			<button type="button" class="btn btn-success" onclick="initOpenPrice();"> 统计收盘价</button> 
				       		</div>
		         	 	</div>
					</div>
				</div>
				
				-->  
				
				
				       
	     </div>
           
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/sale/foot.jsp" %>
  <!-- foot start -->
  
</body>


<!-- 以下是template列表模板的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1) ?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].proNo,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].proName,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].userOwner,'')?></td>		
			<td class="text_c"><?=strUtil.doNull(rows[i].randNumber,'')?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].createTime,'')?></td>	
			<td class="text_r"><?=strUtil.doNull(rows[i].nums,'')?></td>	
			<td class="text_r">￥<?=strUtil.doNull(rows[i].price,'')?></td>	
			<td class="text_c"><?=yesOrNo(rows[i].isSelect)?></td>
			<td class="text_c"><?=yesOrNo(rows[i].isPay)?></td>
			<td class="text_c"><?=strUtil.doNull(rows[i].remark,'')?></td>
             
		</tr>
   <?}?>  		
</script>

</html>

<!-- 以下是js模块区域 -->
<script>
var clickMenu = "match-server";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 10;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "trsNumbers";
tableId = "numberId";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	
 });
//初始化撮合服务
function initMatch(type){
	var index_submit = layer.confirm('您确定要【重启撮合服务】吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var thisUrl="${ctx}/trans/list/?doCode=dymicSql";
		//var paramLoadData = {"trsOrder.w_orderId":"2222","modelTypes":"s_trsOrder","afterMethodKey":"initDealMatching","type":type};
        var paramLoadData = {"pageName":"match-server","formName":"initDealMatching","type":type,"trsOrder.w_orderId":"2222"};
		$.ajax({url: thisUrl,type: "get",dataType: "json" ,data:paramLoadData,
	      success: function(myData){
	    	  console.log(myData);
	        	if(type!="view" && myData){
		        	layer.alert("缓存队列重置成功！");
	        	}
	        }
	    });
	});
}
//初始化开盘价行情
function initOpenPrice(){
	var lastDate = $("#lastDate").val();
	var index_submit = layer.confirm('您确定要【初始化开盘价】吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var thisUrl="${ctx}/trans/list/?doCode=dymicSql";
		// var paramLoadData = {"trsOrder.w_orderId":"2222","modelTypes":"s_trsOrder","beforMethodKey":"initOpenPrice","lastDate":lastDate};
		var paramLoadData = {"pageName":"match-server","formName":"initOpenPrice","lastDate":lastDate,"trsOrder.w_orderId":"2222"};
		$.ajax({url: common_list_url,type: "get",dataType: "json" ,data:paramLoadData,
	      success: function(myData){
	    	  console.log(myData);
	        	if(myData){
	        		layer.alert("开盘价初始化成功！");
	        	}
	        }
	    });
	});
	
}

//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);
	//搜索框去除空格
	$("#wl_proName").val($("#wl_proName").val().trim());
	$("#wl_userOwner").val($("#wl_userOwner").val().trim());
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   if(isShowLog)console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }

//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}



/****  以下是自定义新增方法  ****/
 
 var dateSelect = $('#lastDate').datepicker( {
	language : 'zh-CN',
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true,
});

 
 
</script>



